{% macro render_item(item, submenu=False, parent=False) %}
{% if item.child_items %}

	{% if parent %}

		{%- set dropdown_id = 'id-' + frappe.utils.generate_hash('Dropdown', 12) -%}
		<li class="nav-item dropdown {% if submenu %} dropdown-submenu {% endif %}">
			<a class="navbar-link dropdown-toggle" href="#" id="{{ dropdown_id }}" role="button"
				data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
				{{ _(item.label) }}
			</a>
		  	<ul class="dropdown-menu" aria-labelledby="{{ dropdown_id }}">
				{% for child in item.child_items %}
					{{ render_item(child, True) }}
			  {% endfor %}
			</ul>
		</li>
	{% else %}
		{%- set dropdown_id = 'id-' + frappe.utils.generate_hash('Dropdown', 12) -%}
		<li class="dropdown {% if submenu %} dropdown-submenu {% endif %}">
			<a class="dropdown-item dropdown-toggle" href="#" id="{{ dropdown_id }}" role="button"
				data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
				{{ _(item.label) }}
			</a>
			<ul class="dropdown-menu" aria-labelledby="{{ dropdown_id }}">
				{% for child in item.child_items %}
					{{ render_item(child, True) }}
			{% endfor %}
			</ul>
		</li>
	{% endif %}

{% else %}

	{% if parent %}
	<li class="nav-item">
		<a class="navbar-link" href="{{ (item.url or '')|abs_url }}"
			{% if item.open_in_new_tab %} target="_blank" {% endif %}>
			{{ _(item.label) }}
		</a>
	</li>
	{% else %}
	<a class="dropdown-item" href="{{ (item.url or '') | abs_url }}"
		{% if item.open_in_new_tab %} target="_blank" {% endif %}>
		{{ _(item.label) }}
	</a>
	{% endif %}

{% endif %}
{% endmacro %}

<ul class="navbar-nav">
	{% include "wiki/doctype/wiki_page/templates/navbar_search.html" %}
	{%- for item in navbar_items -%}
		{% if not item.parent_label and item.right -%}
			{{ render_item(item, parent=True) }}
		{%- endif -%}
	{%- endfor %}
	{% if not only_static %}
		{% block navbar_right_extension %}{% endblock %}
	{% endif %}
	<div class="d-block d-sm-none sm-sidebar">
		<!--sidebar-->
	</div>
	{% include "templates/includes/navbar/navbar_login.html" %}


</ul>
{%- if call_to_action -%}
<a class="btn btn-primary navbar-cta" href="{{ call_to_action_url | abs_url }}">
	{{ call_to_action }}
</a>
{%- endif -%}
